<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Classes  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset='utf-8'>
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a title="Classes  Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="index.html">CryptorECC Docs</a> (100% documented)</p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="index.html">CryptorECC Reference</a>
        <img id="carat" src="img/carat.png" />
        Classes  Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Classes/ECPrivateKey.html">ECPrivateKey</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/ECPublicKey.html">ECPublicKey</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Extensions/Data.html">Data</a>
              </li>
              <li class="nav-group-task">
                <a href="Extensions/String.html">String</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Structs/ECError.html">ECError</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/ECSignature.html">ECSignature</a>
              </li>
              <li class="nav-group-task">
                <a href="Structs/EllipticCurve.html">EllipticCurve</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>Classes</h1>
            <p>The following classes are available globally.</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:10CryptorECC12ECPrivateKeyC"></a>
                    <a name="//apple_ref/swift/Class/ECPrivateKey" class="dashAnchor"></a>
                    <a class="token" href="#/s:10CryptorECC12ECPrivateKeyC">ECPrivateKey</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Represents an elliptic curve private key.<br>
Supported curves are:  </p>

<ul>
<li>prime256v1<br></li>
<li>secp384r1<br></li>
<li>NID_secp521r1<br>
You can generate an elliptic curve Key using OpenSSL:<br>
<a href="https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters">https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters</a></li>
</ul>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">pemKey</span> <span class="o">=</span> <span class="s">"""
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIJX+87WJ7Gh19sohyZnhxZeXYNOcuGv4Q+8MLge4UkaZoAoGCCqGSM49
AwEHoUQDQgAEikc5m6C2xtDWeeAeT18WElO37zvFOz8p4kAlhvgIHN23XIClNESg
KVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA==
-----END EC PRIVATE KEY-----
"""</span>
<span class="k">let</span> <span class="nv">privateKey</span> <span class="o">=</span> <span class="k">try</span> <span class="kt">ECPrivateKey</span><span class="p">(</span><span class="nv">key</span><span class="p">:</span> <span class="n">pemKey</span><span class="p">)</span>
<span class="k">let</span> <span class="nv">signature</span> <span class="o">=</span> <span class="s">"Hello world"</span><span class="o">.</span><span class="nf">sign</span><span class="p">(</span><span class="nv">with</span><span class="p">:</span> <span class="n">privateKey</span><span class="p">)</span>
</code></pre>

                        <a href="Classes/ECPrivateKey.html" class="slightly-smaller">See more</a>
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">ECPrivateKey</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:10CryptorECC11ECPublicKeyC"></a>
                    <a name="//apple_ref/swift/Class/ECPublicKey" class="dashAnchor"></a>
                    <a class="token" href="#/s:10CryptorECC11ECPublicKeyC">ECPublicKey</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Represents an elliptic curve public key.
Supported curves are:  </p>

<ul>
<li>prime256v1<br></li>
<li>secp384r1<br></li>
<li>NID_secp521r1<br>
You can generate an elliptic curve Key using OpenSSL:<br>
<a href="https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters">https://wiki.openssl.org/index.php/Command_Line_Elliptic_Curve_Operations#Generating_EC_Keys_and_Parameters</a><br></li>
</ul>
<h3 id='usage-example' class='heading'>Usage Example:</h3>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">pemKey</span> <span class="o">=</span> <span class="s">"""
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEikc5m6C2xtDWeeAeT18WElO37zvF
Oz8p4kAlhvgIHN23XIClNESgKVmLgSSq2asqiwdrU5YHbcHFkgdABM1SPA==
-----END PUBLIC KEY-----
"""</span>
<span class="k">let</span> <span class="nv">publicKey</span> <span class="o">=</span> <span class="k">try</span> <span class="kt">ECPublicKey</span><span class="p">(</span><span class="nv">key</span><span class="p">:</span> <span class="n">pemKey</span><span class="p">)</span>

<span class="k">let</span> <span class="nv">base64Sig</span> <span class="o">=</span> <span class="s">"MEYCIQCvgBLn+tQoBDBR3D2G3485GloYGNxuk6PqR4qjr5GDqAIhAKNvsqvesVBD/MLub/KAyzLLNGtUZyQDxYZj/4vmHwWF"</span>
<span class="k">let</span> <span class="nv">signature</span> <span class="o">=</span> <span class="k">try</span> <span class="kt">ECSignature</span><span class="p">(</span><span class="nv">asn1</span><span class="p">:</span> <span class="kt">Data</span><span class="p">(</span><span class="nv">base64Encoded</span><span class="p">:</span> <span class="n">base64Sig</span><span class="p">))</span> 

<span class="k">let</span> <span class="nv">verified</span> <span class="o">=</span> <span class="n">signature</span><span class="o">.</span><span class="nf">verify</span><span class="p">(</span><span class="nv">plaintext</span><span class="p">:</span> <span class="s">"Hello world"</span><span class="p">,</span> <span class="nv">using</span><span class="p">:</span> <span class="n">publicKey</span><span class="p">)</span>
</code></pre>

                        <a href="Classes/ECPublicKey.html" class="slightly-smaller">See more</a>
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">ECPublicKey</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2019 <a class="link" href="https://github.com/IBM-Swift/BlueECC" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2019-03-12)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.1</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
